﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.SANY.Util;

namespace PMS.SANY.Entity
{
    /// <summary>
    /// 物料抓取顺序
    /// </summary>
    public partial class MaterielSortingSequence : BusEntity
    {
        /// <summary>
        /// 分拣配置编号
        /// </summary>
        public string SortingConfigId { set; get; }

        /// <summary>
        /// 缓存位编号
        /// </summary>
        public string LocationId { set; get; }

        /// <summary>
        /// 抓取顺序号
        /// </summary>
        public int OrderNo { set; get; }

        /// <summary>
        /// 连续抓取次数
        /// </summary>
        public int Quantity { set; get; }
    }

    public partial class MaterielSortingSequence : BusEntity
    {
        public MaterielSortingConfig SortingConfig { set; get; }

        /// <summary>
        /// 料位信息
        /// </summary>
        public MaterielSortingLocation SortingLocation { set; get; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class MaterielSortingSequenceTypeConfig : BusEntityTypeConfig<MaterielSortingSequence>, IEntityTypeConfiguration<MaterielSortingSequence>
    {
        public override void Configure(EntityTypeBuilder<MaterielSortingSequence> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            builder.HasOne(p => p.SortingConfig).WithMany(p => p.Sequences).HasForeignKey(p => p.SortingConfigId);
            builder.HasOne(p => p.SortingLocation).WithMany(p => p.Sequences).HasForeignKey(p => p.LocationId);
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.SortingConfigId).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.LocationId).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.OrderNo).IsRequired();
            builder.Property(p => p.Quantity).IsRequired();
            #endregion

            #region 备注
            builder.HasComment("物料抓取顺序设置");
            builder.Property(p => p.SortingConfigId).HasComment("分拣配置编号");
            builder.Property(p => p.LocationId).HasComment("缓存位编号");
            builder.Property(p => p.OrderNo).HasComment("抓取顺序号");
            builder.Property(p => p.Quantity).HasComment("连续抓取次数");
            #endregion

            #region 种子数据
            #endregion
        }
    }
}
